package md.frolov.bible.indexes;

import java.io.File;

/**
 * Index container
 * @author gusto
 *
 */
public class IXBible extends IX{
	public IXBible(File file) {
		super(file);
	}

	public long getOffset(String key){
		int ix = 0;
		for(int i=0; i<keys.size();i++){
			String ixKey = keys.get(i);
			if(key.startsWith(ixKey)){
				if((key+".").startsWith(ixKey+".")){
					ix = i;
					break;
				}
			}
		}
		
		//psalms chapter incosistence
		//search for better way
		if(key.contains("psa") && ix>0) ix-=1;

		return offsets.get(ix).longValue();
	}
	
	@Override
	public String getType() {
		return this.getClass().getName();
	}
}
